#include "StdAfx.h"

#include "ApproachTrace.h"

CApproachTrace::CApproachTrace(CAsteroidOrbitParam::Ptr pAsteroidOrbitParam, ListPtrApproachs &appList) // list will be cleaned
{
	m_pAsteroidOrbitParam = pAsteroidOrbitParam;
	m_listPtrApproaches.swap(appList);
}

void CApproachTrace::Merge(const Ptr pOtherTrace)
{
	m_listPtrApproaches.merge(pOtherTrace->m_listPtrApproaches, CApproach::CompareApproachesByTime);
}

void CApproachTrace::GetApproachesList(ListPtrApproachs & listPtrApproaches)
{
	ListPtrApproachs::iterator itApp = m_listPtrApproaches.begin();
	ListPtrApproachs::iterator endApp = m_listPtrApproaches.end();
	for(; itApp != endApp; ++itApp)
	{
		CApproach::Ptr pApp = *itApp;
		listPtrApproaches.push_back(pApp);
	}
}

void CApproachTrace::GetApproachesList(const CGridParam &ranges, ListPtrApproachs & listPtrApproaches)
{
	ListPtrApproachs::iterator itApp = m_listPtrApproaches.begin();
	ListPtrApproachs::iterator endApp = m_listPtrApproaches.end();
	for(; itApp != endApp; ++itApp)
	{
		CApproach::Ptr pApp = *itApp;
		if( ranges.IsIncludedTime(pApp->m_dTime) )
			listPtrApproaches.push_back(pApp);		
	}
}

const CAsteroidOrbitParam::Ptr CApproachTrace::GetAsteroidOrbitParam() const
{
	return m_pAsteroidOrbitParam;
}
